package com.mall.server.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.commons.utils.PageUtils;
import com.mall.dubbo.api.PmsProductApi;
import com.tanhua.model.domain.PmsProduct;
import com.tanhua.model.dto.ProductListDto;
import com.tanhua.model.vo.PageVo;
import com.tanhua.model.vo.PmsProductParam;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductService {
    @DubboReference
    private PmsProductApi pmsProductApi;


    public PageVo list(ProductListDto productListDto) {
        Page page = pmsProductApi.getList(productListDto);
        PageVo pageVo = PageUtils.getPageVo(page);

        return pageVo;
    }


    /**
     * 商品列表批量上下架商品
     * @param ids
     * @param publishStatus
     * @return
     */
    public void updatePublishStatus(List<Long> ids, Integer publishStatus) {
        pmsProductApi.updatePublishStatus(ids,publishStatus);
    }
    /**
     * 批量上下架商品
     * @param ids
     * @param publishStatus
     * @return
     */
    public void updateNewStatus(List<Long> ids, Integer publishStatus) {
        pmsProductApi.updateNewStatus(ids,publishStatus);
    }
    /**
     * 批量推荐与否
     * @param ids
     * @param publishStatus
     * @return
     */
    public void updateRecommendStatus(List<Long> ids, Integer publishStatus) {
        pmsProductApi.updateRecommendStatus(ids,publishStatus);
    }

    /**
     * 添加商品
     * @param pmsProductParam
     */
    public void productCreate(PmsProductParam pmsProductParam) {
        pmsProductApi.productCreate(pmsProductParam);
    }

    /**
     * 修改商品时回显
     * @param id
     * @return
     */
    public PmsProductParam updateInfoById(Long id) {
        return pmsProductApi.updateInfoById(id);
    }

    public void updateDeleteStatus(List<Long> ids, Integer deleteStatus) {
        pmsProductApi.updateDeleteStatus(ids,deleteStatus);
    }

    /**
     * 更新商品
     * @param id
     */
    public void updateById(Long id,PmsProductParam pmsProductParam) {
        pmsProductApi.updateById(id,pmsProductParam);
    }

    /**
     * 根据商品名称或货号模糊查询
     * @param keyword
     * @return
     */
    public List<PmsProduct> productSimpleList(String keyword) {
        return pmsProductApi.productSimpleList(keyword);
    }
}
